package entity

import (
	"gitee.com/djaf/my-certs/app/data/dxo"
	"github.com/starter-go/base/lang"
)

// Account ...
type Account struct {
	ID dxo.AccountID

	Base

	KeyPair        dxo.KeyPairID
	ACMEServiceURL string
	DebugMode      bool

	Email    string `gorm:"unique"`
	Selector int64  `gorm:"unique"` // 1=current
}

// SetAsCurrent ...
func (inst *Account) SetAsCurrent(current bool) {
	if current {
		inst.Selector = 1
	} else {
		now := lang.Now()
		inst.Selector = now.Int()
	}
}
